import static org.junit.Assert.*;


import java.util.HashMap;
import java.util.Map;

import org.junit.Test;

import edu.gatech.wheresmystuff.model.ILogin;
import edu.gatech.wheresmystuff.model.LoginModel;
import edu.gatech.wheresmystuff.model.User;

/**
 * Primarily checks the checkLogin() method of LoginModel;
 * 
 * @author Ses Goe
 *
 */
/**
 * Tests the LoginModel's checkLogin Method's possible test cases
 * @author Ses
 *
 */
public class SesTest {

	private Map<String, User> usermap;
	private ILogin model;
	
	public SesTest() {
		usermap = new HashMap<String, User>();
		User test = new User();
		test.setAdmin(0);
		test.setID(1);
		test.setUsername("test");
		test.setPassword("test");
		test.setTries(3);
		usermap.put(test.getUid(), test);
		model = new LoginModel(null);
	}
	
	@Test
	public void test() {
		assertTrue (model.checkLogin("test", "test", usermap)); 					//valid login
		try {
			assertFalse(model.checkLogin("test", "somethingthatisnttest", usermap));	//invalid password
		}
		catch (NullPointerException e) {
		}
		assertFalse(model.checkLogin("somethingthatisnttest", "test", usermap));	//invalid username
		assertFalse(model.checkLogin("test", null, usermap));						//null for PW
		assertFalse(model.checkLogin(null, "test", usermap));						//null for username
		assertFalse(model.checkLogin(null, null, usermap));							//both null
		assertFalse(model.checkLogin("test", "test", null));						//usermap somehow is null
		assertFalse(model.checkLogin(null, null, null));							//all of the things are null
		
		User test = usermap.get("test");
		test.setTries(0);
		
		assertFalse(model.checkLogin("test", "test", usermap));
		
	}

}
